package process_demo.attributes.id_name;

/**
 * @author haomin
 * @date 2022/04/19 19:36
 **/
public class Main2 {
    static class MyThread extends Thread {
        public MyThread() {
        }

        public MyThread(String name) {
            setName(name);
        }

        @Override
        public void run() {
            System.out.println(this.getName() + ": "+this.getId());
        }
    }

    public static void main(String[] args) {
        // 当前线程
        Thread thread = Thread.currentThread();
        System.out.println(thread.getName()+ ": " + thread.getId());

        MyThread t1 = new MyThread("浩民1");
        t1.start();

        MyThread t2 = new MyThread();
        t2.setName("浩民2");
        t2.start();

        MyThread t3 = new MyThread();
        t3.start();
    }
}